/**
 * 表单校验工具
 * @params formRefs=[] 表单实例的集合
 */
export const checkForm = (formRefs: any, fun?: () => void) => {
  return new Promise((req) => {
    const _status: boolean[] = []
    try {
      formRefs.forEach((ele: any) => {
        ele.validate((valid: boolean) => {
          _status.push(valid)
          if (_status.length === formRefs.length) {
            req(_status)
          }
        })
      })
    } catch (error) {
      req(_status)
    }
  }).then((_status: any) => {
    if (!_status.includes(false)) fun && fun()
    return !_status.includes(false)
  })
}
